package com.example.demo.controller;

import com.example.demo.entity.ResponseResult;
import com.example.demo.entity.Sales;
import com.example.demo.service.SalesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

@RestController
@RequestMapping("/sales")
@Api(tags = "销售单接口")
public class SalesController {

    @Resource
    private SalesService salesService;

    @GetMapping
    @ApiOperation(value = "查询全部订单")
    public ResponseResult getList(){
        return salesService.getList();
    }

    @PostMapping
    @ApiOperation(value = "录入销售单")
    public ResponseResult saveSales(@RequestBody Sales sales){
        return salesService.saveSales(sales);
    }

    @PutMapping
    @ApiOperation(value = "修改销售单")
    public ResponseResult updateSales(@RequestBody Sales sales){
        return salesService.updateSales(sales);
    }

    @DeleteMapping("/deleteById")
    @ApiOperation(value = "根据id删除")
    public ResponseResult deleteById(@RequestParam String id){
        return salesService.deleteById(id);
    }
}
